import socket



def send(data):
    # the format of data are defined in mian.py
    client = socket.socket()
    client.connect(('192.168.31.21',8888))
    print('[sockets.py:send():]---client socket connect to server')
    # send data
    client.send(data.encode('utf-8'))

    # receive from server
    data_back = client.recv(256)
    print("[from server:]" + data_back.decode('utf-8'))

    #over message
    quit_data = 'q'
    client.send(quit_data.encode('utf-8'))
    client.close()

    return 1


# def connect_over():
    

'''
if __name__ == "__main__":
    client = socket.socket()
    client.connect(('192.168.31.21',8888))
    print('client is running')

    send_data = 'zhh is ddddddddd:'
    client.send(send_data.encode('utf-8'))

    data = client.recv(1024)
    print(data.decode('utf-8'))

    send_data = 'q'
    client.send(send_data.encode('utf-8'))
    client.close()

'''